package cn.iocoder.yudao.module.erp.dal.mysql.invoice;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.invoice.vo.InvoicePageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.invoice.InvoiceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * ERP 发票 Mapper
 *
 * @author 源码
 */
@Mapper
public interface InvoiceMapper extends BaseMapperX<InvoiceDO> {

    default PageResult<InvoiceDO> selectPage(InvoicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InvoiceDO>()
                .eqIfPresent(InvoiceDO::getInvoiceNumber, reqVO.getInvoiceNumber())
                .eqIfPresent(InvoiceDO::getSupplierId, reqVO.getSupplierId())
                .eqIfPresent(InvoiceDO::getInvoiceValue, reqVO.getInvoiceValue())
                .eqIfPresent(InvoiceDO::getFileUrl, reqVO.getFileUrl())
                .betweenIfPresent(InvoiceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InvoiceDO::getId));
    }

    List<InvoiceDO> selectListByIds(List<String> invoiceIds);

    default List<InvoiceDO> selectListByInvoiceNumbers( List<Long> invoiceNumbers) {
        return selectList(InvoiceDO::getId,invoiceNumbers);
    }

    default List<InvoiceDO> getByOrderIntegrateIds( List<String> orderIntegrateIds ) {
        return selectList(InvoiceDO::getOrderIntegrateId,orderIntegrateIds);
    }

}